package com.aqie.demo.bean;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author: aqie
 * @create: 2020-12-26 19:47
 **/
@Data
@AllArgsConstructor
public class User implements Comparable<User>{
    private int id;
    private String name;

    @JsonIgnore
    @JsonProperty
    @JsonFormat
    @JsonIgnoreProperties
    @JsonSerialize   // 自定义序列化
    @JsonInclude
    private int age;

    public User() {
    }

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public User(String name) {
        this.name = name;
    }

    @Override
    public int compareTo(User o) {
        return (this.age - o.age) + this.name.compareTo(o.name);
    }
}
